package org.rescue.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

import org.rescue.search.*;


public class SaveDataset extends HttpServlet {

	public void doPost(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		
		DatasetDB datasetDB = new DatasetDB();
	
		HttpSession session = request.getSession();
		if(session.getAttribute("dataset") != null) {

			Dataset d = (Dataset)session.getAttribute("dataset");
			datasetDB.writeDataset(d);
			
		}	
		
		// get updated listing of datasets to display in select box
		ArrayList<DatasetListing> listing = datasetDB.getDatasetListing(); 			
		request.setAttribute("listing", listing);	

		RequestDispatcher view = request.getRequestDispatcher("manage_configuration.jsp");
		view.forward(request,response);

	}
}
